package cn.xhjava.crm.settings.service.impl;

import cn.xhjava.crm.commons.util.ExceptionUtil;
import cn.xhjava.crm.settings.controller.DicTypeContoller;
import cn.xhjava.crm.settings.domain.DicType;
import cn.xhjava.crm.settings.domain.DicValue;
import cn.xhjava.crm.settings.mapper.DicTypeMapper;
import cn.xhjava.crm.settings.service.DicTypeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author Xiahu
 * @create 2023/7/25 0025
 */
@Service
public class DicTypeServiceImpl implements DicTypeService {

    @Autowired
    private DicTypeMapper dicTypeMapper;

    @Override
    public List<DicType> selectForPage(Map<String, Object> map) throws Exception {
        return dicTypeMapper.selectForPage(map);
    }

    @Override
    public int selectCountForPage(Map<String, Object> map) throws Exception {
        return dicTypeMapper.selectCountForPage(map);
    }

    @Override
    public int delete(String[] ids) throws Exception {
        int res = 1;
        for (String id : ids) {
            dicTypeMapper.deleteByPrimaryKey(id);
        }
        return res;
    }

    @Override
    public int add(DicType dicType) throws Exception {
        return dicTypeMapper.insert(dicType);
    }

    @Override
    public DicType selectByCode(String code) throws Exception {
        return dicTypeMapper.selectByPrimaryKey(code);
    }

    @Override
    public DicType selectDetailById(String id) throws Exception {
        return dicTypeMapper.selectByPrimaryKey(id);
    }

    @Override
    public int update(DicType dicType) throws Exception {
        return dicTypeMapper.update(dicType);
    }

    @Override
    public List<DicValue> selectAll() throws Exception {
        return dicTypeMapper.selectAll();
    }
}
